#include<iostream>
using namespace std;

string read() {
    char c;
    int num = 1;
    string s = "", ss;
    while(cin >> c) {
        if(c == '[') {
            cin >> num;
            ss = read();
            while(num--)   s += ss;
        } else {
            if(c == ']')    return s;
            else            s += c;
        }
    }
    return s;
}

int main() {
    cout << read() << endl;
    return 0;
}